package com.joplus.housekeeper.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.joplus.housekeeper.R;
import com.joplus.housekeeper.bean.AccompentHospitalBean;
import com.joplus.housekeeper.utils.StringUtils;
import com.nostra13.universalimageloader.core.ImageLoader;

import java.util.List;

/**
 * author： ccm
 * time： 2017/6/21.
 * description：
 */

public class AccomentHosptialAdapter extends BaseAdapter {
    private Context mContext;
    private List<AccompentHospitalBean.DataBean.ContentBean> hosptialList;
    private final LayoutInflater layout;

    public AccomentHosptialAdapter(Context context, List<AccompentHospitalBean.DataBean.ContentBean> hosptialList) {
        mContext = context;
        this.hosptialList = hosptialList;
        layout = LayoutInflater.from(mContext);
    }

    @Override
    public int getCount() {
        return hosptialList.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View view = layout.inflate(R.layout.item_hostipal, null);

        ImageView iv = (ImageView) view.findViewById(R.id.iv);
        TextView tv_name = (TextView) view.findViewById(R.id.tv_name);
        TextView tv_address = (TextView) view.findViewById(R.id.tv_address);
        TextView tv_type = (TextView) view.findViewById(R.id.tv_type);
        ImageLoader.getInstance().displayImage(hosptialList.get(position).getSmallImage(), iv);


        StringUtils.setText(tv_address, hosptialList.get(position).getAddress());
        StringUtils.setText(tv_name, hosptialList.get(position).getName());
        if ("1".equals(hosptialList.get(position).getLevelInfo())) {
            tv_type.setText("三级");
        } else if ("2".equals(hosptialList.get(position).getLevelInfo())) {
            tv_type.setText("三甲");
        } else if ("3".equals(hosptialList.get(position).getLevelInfo())) {
            tv_type.setText("三乙");
        } else if ("4".equals(hosptialList.get(position).getLevelInfo())) {
            tv_type.setText("二级");
        } else if ("5".equals(hosptialList.get(position).getLevelInfo())) {
            tv_type.setText("二甲");
        } else if ("6".equals(hosptialList.get(position).getLevelInfo())) {
            tv_type.setText("二乙");
        } else if ("7".equals(hosptialList.get(position).getLevelInfo())) {
            tv_type.setText("社区医院");
        }
        return view;
    }
}
